infoWindow = function($)
{
  var init = function()
  {
    $(".infoWindow").mouseenter(showWindow);
    $(".infoWindow,.infoWindowClick").click(showWindow);
    $(".infoWindowPopup .closeButton").click(hideParent);
    $(".infoWindowPopup")
        .addClass(
            "ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable ui-resizable dialogWithDropShadow")
        .mouseleave(hideWindow);
  }, showWindow = function(event)
  {
    var popUp = $("#infoWindow-" + this.id);
    popUp.show();
    var position = $(this).offset();
    popUp.css("left", position.left - (popUp.width() / 2));
    popUp.css("top", Math.max(10, position.top - (popUp.height() / 2)));
  }, hideWindow = function()
  {
    $(this).hide();
  }, hideParent = function()
  {
    $(this).parent().hide();
  };

  return {
    init : init
  };
}(jQuery);

$(function()
{
  infoWindow.init();
});